Mock.mock("/js/compent/Tea.js", "post", function () {
    //获取本地存储
    let teaStr = localStorage.tea;
    return teaStr;
})

Mock.mock("/js/fun", "post", function (data) {
    let obj = JSON.parse(data.body);

    // 获取本地存储
    let teaStr = localStorage.tea;
    let teaArrObj=JSON.parse(teaStr);
    
    //判断obj是否为0
    if (obj.index == 0) {
        return teaArrObj;
    }
    let teaObjArr = JSON.parse(teaStr);
    //将要返回的对象存储到数组中
    let arr = [];
    for (let i = 0; i < teaObjArr.length; i++) {
        if (teaObjArr[i].teaClass == obj.index) {
            arr.push(teaObjArr[i]);
        }
    }
    return arr;
})
Mock.mock("/js/fun1","post",function(obj){
    debugger
    let teaNameobj=JSON.parse(obj.body);
    let xqStr=localStorage.xq;
    let teaStr=localStorage.tea;
    let teaobj=JSON.parse(teaStr);
    if(xqStr==""||xqStr==null||xqStr==undefined||xqStr==[]){
        for(let i=0;i<teaobj.length;i++){
            if(teaobj[i].teaName==teaNameobj.teaName){
                localStorage.xq=JSON.stringify(teaobj[i]);
                return true;
            }
        }
    }else{
        localStorage.xq="";
        for(let i=0;i<teaobj.length;i++){
            if(teaobj[i].teaName==teaNameobj.teaName){
                localStorage.xq=JSON.stringify(teaobj[i]);
                return true;
            }
        }
    }
})
